home *** CD-ROM | disk | FTP | other *** search
- Path: library.erc.clarkson.edu!rpi!not-for-mail
- From: Miljenko Cvjetko <cvjetko@rt.e-technik.uni-erlangen.de>
- Newsgroups: comp.lang.c++,comp.lang.c++.moderated,comp.sys.hp.hpux
- Subject: Re: [Q] gcc 2.7.2 + STL + HP_UX 9.05 = memory_leak ?
- Date: 28 Mar 1996 13:12:56 -0000
- Organization: Regionales Rechenzentrum Erlangen, Germany
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: Dietmar.Kuehl@uni-konstanz.de
- Message-ID: <4je38o$mdj@netlab.cs.rpi.edu>
- References: <4j66lu$olu@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
- X-Original-Date: Thu, 28 Mar 1996 10:35:12 +0100
-
- On 25 Mar 1996, Miljenko Cvjetko wrote:
-
- > I was testing storing ptrs in STL container when I found
- > out a memory-leak in STL implementation in following
- > example:
- >
- > # include <list.h> // STL list
- > # include <stdlib.h>
- >
- > class X
- > {
- > protected:
- > list<int> nodes_; // this line causes
- > // memory leak problems!!!
- > // under HP_UX 9.05
- > // not under Borland C/C++ + DOS
- > };
- >
- > void f()
- > {
- > X x1;
- > }
- >
- > int main()
- > {
- > memorymap(1);
- > f();
- > memorymap(1); // list is out of scope
- > return 0;
- > }
- > - ------------------------------------------
- > Result:
- >
- > arenastart : 0
- > arenaend : 0
- > # of blocks : 0
- > # of free blocks : 0
- > # of used blocks : 0
- > # of smblk blks : 0
- > total space used : 0
- > space in free blocks : 0
- > space in used blocks : 0
- > space in smblk blocks : 0
- > 1073748164: node block 8192
- > 1073756356: free 1848
- >
- > arenastart : 1073748164
- > arenaend : 1073758204
- > # of blocks : 2
- > # of free blocks : 1
- > # of used blocks : 1
- > # of smblk blks : 0
- > total space used : 10040
- > space in free blocks : 1848
- > space in used blocks : 8192
- > space in smblk blocks : 0
- > - -------------------------------------------
- > In addition, this code was compiled under
- > BC 4.5 and had no memory leak! Am I
- > misinterpreting memorymap() function call?
- > Same was with some other containers (set,vector).
- > Any suggestions?
- >
- > Thanx in advance
- > Regards
- > m.
- >
-
- I got an answer and suggestion from James Kanze and he had right,
- suspected block was some sort of pseudo-static allocation by the
- implementation and it wasn't ever freed, and the number of the unfreed
- blocks didn't increase, when tested in a loop.
-
- Thanx a lot James
-
- Regards
-
- miljenko
-
- [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
- [ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
- [ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
- [ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
-